//
//  FeedBackViewController.m
//  YJlandlord
//
//  Created by 文彬 on 2018/6/26.
//  Copyright © 2018年 文彬. All rights reserved.
//

#import "FeedBackViewController.h"
#import "InputItemTableViewCell.h"
#import "WBTextView.h"
#import "UILabel+ChangeLineSpaceAndWordSpace.h"

@interface FeedBackViewController ()<UITableViewDelegate,
    UITableViewDataSource>

@property (strong, nonatomic) UITableView *listTableView;

@end

@implementation FeedBackViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"意见反馈";
    
    [self initPageControl];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark 页面相关
- (void)initPageControl{
    
    [self.view addSubview:self.listTableView];
    [self.listTableView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.right.equalTo(@0);
        make.top.equalTo(@0);
        make.bottom.equalTo(@0);
    }];
    
    [StaticTools addTableViewFootButton:self.listTableView title:@"提交" titleFont:[UIFont systemFontOfSize:18] backgroundColor:kMainOriginColor titleColor:[UIColor whiteColor] buttonHeight:48 topMargin:10 leftMargin:20 click:^(id param) {
        
    }];
}

#pragma mark UITableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section==0) {
        return 300;
    }
   
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section==1) {
        InputItemTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"InputItemTableViewCell"];
        cell.titleLabl.text = @"联系方式";
        cell.inputTxtField.placeholder = @"联系电话";
        return cell;
    }
    

    UITableViewCell*  cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"iden"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    WBTextView *txtView = [[WBTextView alloc]init];
    txtView.font = [UIFont systemFontOfSize:15];
    txtView.placeholder = @"请输入您的意见。(500字以内)";
    txtView.layer.cornerRadius = 5;
    txtView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    txtView.layer.borderWidth = 0.5;
    [cell.contentView addSubview:txtView];
    [txtView makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(@10);
        make.right.equalTo(@-10);
        make.height.equalTo(@200);
    }];
    
    UILabel *messLabel = [[UILabel alloc]init];
    messLabel.font = [UIFont systemFontOfSize:13];
    messLabel.textColor = kSecTitleColor;
    messLabel.numberOfLines = 0;
    messLabel.text = @"您的每一条反馈我们都会仔细阅读，但我们无法保证每一条都能及时回复，如果您有紧急问题需要咨询，请直接拨打热线电话联系我们：400-135-3246，谢谢您的理解。";
    [cell.contentView addSubview:messLabel];
    [messLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.top.equalTo(txtView.bottom).offset(10);
        make.right.equalTo(@-10);
        make.bottom.equalTo(@-5);
    }];
    [UILabel changeLineSpaceForLabel:messLabel WithSpace:4];
    
   
    
    return cell;
}

#pragma mark getter
- (UITableView*)listTableView{
    if (_listTableView==nil) {
        _listTableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _listTableView.delegate = self;
        _listTableView.dataSource = self;
        _listTableView.sectionFooterHeight = 0;
        _listTableView.separatorColor = kLineColor;
        _listTableView.backgroundColor = [UIColor clearColor];
        _listTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_listTableView registerNib:[UINib nibWithNibName:@"InputItemTableViewCell" bundle:nil] forCellReuseIdentifier:@"InputItemTableViewCell"];
    }
    
    return _listTableView;
}


@end
